//
//  SeJueShuZiTestViewController.m
//  安好
//
//  Created by qinlongqing on 14-9-13.
//  Copyright (c) 2014年 冯凯. All rights reserved.
//

#import "SeJueShuZiTestViewController.h"
#import "SeJueTestViewController.h"
#import "AppConfig.h"

//initData
#define kZhengChang                  @"zhengChangRen"

#define kXianTianZhongJi             @"xianTianZhongJi"
#define kXianTianCiZhongJi           @"xianTianCiZhongJi"
#define kXianTianQingJi              @"xianTianQingJi"
#define kXianTianJiQingJi            @"xianTianJiQingJi"

#define kHouTianSeJueZhangAi                           @"houTianSeJueZhangAi"
#define kHouTianHongLvYiChang_ZiSeKeNengZhangAi        @"houTianHongLvZhangAi"
#define kHouTianHongLvZhengChang_ZiSeKeNengZhangAi     @"houTianHongLvZhangAi"
#define kHouTianZiSeYiChang_HongLvKeNengZhangAi        @"houTianZiSeZhangAi"
#define kHouTianZiSeZhengChang_HongLvKeNengZhangAi     @"houTianZiSeZhangAi"


//step
#define kChangGuiStep                        @"1"
#define kXianTian_1234Step                   @"2-1"
#define kXianTian_123Step                    @"2-2"
#define kXianTian_12Step                     @"2-3"
#define kRedAndGreenDecideStep               @"redAndGreenDecide"
#define kHouTianHongLvAndPurDecideStep_1     @"houTianHongLvAndPurDecide_1"
#define kHouTianHongLvAndPurDecideStep_2     @"houTianHongLvAndPurDecide_2"


//packet
#define kChangGuiShuZi                      @"changGuiShuZi"
#define kChangGuiTuXing                     @"changGuiTuXing"
#define kXianTianCeShiShuZi_1234            @"xianTianCeShiShuZi_1234"
#define kXianTianCeShiTuXing_1234           @"xianTianCeShiTuXing_1234"
#define kXianTianCeShiShuZi_123             @"xianTianCeShiShuZi_123"
#define kXianTianCeShiTuXing_123            @"xianTianCeShiTuXing_123"
#define kXianTianCeShiShuZi_12              @"xianTianCeShiShuZi_12"
#define kXianTianCeShiTuXing_12             @"xianTianCeShiTuXing_12"
#define kRedAndGreenDecideShuZi             @"redAndGreenDecideShuZi"
#define kRedAndGreenDecideTuXing            @"redAndGreenDecideTuXing"
#define kHouTianCeShiStep2ShuZi             @"houTianCeShiStep2_ShuZi"
#define kHouTianCeShiStep2TuXing            @"houTianCeShiStep2_TuXing"



@interface SeJueShuZiTestViewController ()
{
    UILabel *tuPianShuoMingLabel;
    UIImageView *tuPianImageView;
    UILabel *tiShiLabel;

    UIButton *button1;
    UIButton *button2;
    UIButton *button3;
    UIButton *button4;
    
    NSInteger seJueType;//通过下面三个确定是：正常、先天、后天
    NSInteger seJueZhengChang;//常规测试
    NSInteger seJueYiChang;//常规测试
    NSInteger seJueWuFaDuChu;//常规测试
    
    NSInteger seJueLevel;
    
    NSInteger isRedAndGreenDecide;//是否是重复确认红绿色盲
    
    NSInteger isSecondDecideRedAndGreen;//是否是第二次区分红绿色弱
    
    NSInteger seJueRoG;
    
    NSInteger seJueR;
    NSInteger seJueG;
    
    NSInteger seJueP;
    NSInteger seJueRG;
    
    NSMutableDictionary *allDataDict;
    NSMutableDictionary *dataPacketDict;
    
    NSMutableArray *changGuiShuZi;//当进行常规测试时、从预先生成的字典中得到常规数字测试所需的数据
    NSMutableArray *xianTianShuZi_1234;//先天测试，区分1234
    NSMutableArray *xianTianShuZi_123;//先天测试，区分123
    NSMutableArray *xianTianShuZi_12;//先天测试，区分12
    NSMutableArray *redAndGreenDecideShuZi;//红绿区别(数字)
    NSMutableArray *houTianCeShiStep2ShuZi;//后天数字测试
    
    NSMutableArray *changGuiTuXing;//当进行常规测试时、从预先生成的字典中得到常规图形测试所需的数据
    NSMutableArray *xianTianTuXing_1234;//先天图形测试，区分1234
    NSMutableArray *xianTianTuXing_123;//先天图形测试，区分123
    NSMutableArray *xianTianTuXing_12;//先天图形测试，区分12
    NSMutableArray *redAndGreenDecideTuXing;//图形红绿区别(图形)
    NSMutableArray *houTianCeShiStep2TuXing;//图形后天数字测试

    NSMutableArray *changGuiHunHe;//当进行常规测试时、从预先生成的字典中得到常规数字和图形的混合测试所需的数据
    NSMutableArray *xianTianHunHe_1234;//先天数字和图形的混合测试，区分1234
    NSMutableArray *xianTianHunHe_123;//先天数字和图形的混合测试，区分123
    NSMutableArray *xianTianHunHe_12;//先天数字和图形的混合测试，区分12
    NSMutableArray *redAndGreenDecideHunHe;//数字和图形的混合红绿区别(混合)
    NSMutableArray *houTianCeShiStep2HunHe;//数字和图形的混合后天数字测试

    
    NSInteger currentTestImageNumber;//当前显示图片的编号
    NSString *currentTestStep;//当前测试到第几步
    
    UIView *selectRedOrGreenView;
    UIView *selectRedOrGreenBGView;
//    UILabel *tiShiLabel;
    
    
    CGFloat tuPianShuoMingLabelHeight;
    
    CGFloat tuPianImageViewWidth;
    CGFloat tuPianImageViewHeight;
    
    CGFloat tiShiLabelHeight;
    
    CGFloat buttonHeight;
    
    CGFloat selectRedOrGreenViewWidth;
    CGFloat selectRedOrGreenViewHeight;
}
@end

@implementation SeJueShuZiTestViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self makeNavBar];
    
    if (self.testWay == shuZiTestWay) {
        self.navigationItem.title = @"数字测试";
    }
    else if (self.testWay == tuXingTestWay){
        self.navigationItem.title = @"图形测试";
    }
    else if (self.testWay == hunHeTestWay){
        self.navigationItem.title = @"混合测试";
    }
    self.view.backgroundColor = UIColorFromRGB(0xe7f1f4);
    
    dataPacketDict = [[NSMutableDictionary alloc]init];
    allDataDict = [[NSMutableDictionary alloc]init];
    
    [self initAllData];

    [self doDataPacket];
    
    if (kScreenWidth == 414) {
        tuPianShuoMingLabelHeight = 24;
        tuPianImageViewWidth = 360;
        tuPianImageViewHeight = 276;
        tiShiLabelHeight = 48;
        buttonHeight = 42;
        selectRedOrGreenViewWidth = 348;
        selectRedOrGreenViewHeight = 173;
    }
    else{
        tuPianShuoMingLabelHeight = 20;
        tuPianImageViewWidth = 300;
        tuPianImageViewHeight = 230;
        tiShiLabelHeight = 40;
        buttonHeight = 35;
        selectRedOrGreenViewWidth = 290;
        selectRedOrGreenViewHeight = 144;
    }
    CGFloat space = (kScreenHeight - tuPianShuoMingLabelHeight - tuPianImageViewHeight - tiShiLabelHeight - buttonHeight - 64)/9;//每个空间之间的距离

    
    tuPianImageView = [[UIImageView alloc]init];
    tuPianImageView.frame = CGRectMake((kScreenWidth - tuPianImageViewWidth)/2, 2*space, tuPianImageViewWidth, tuPianImageViewHeight);
    tuPianImageView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:tuPianImageView];
    
    
    tuPianShuoMingLabel = [[UILabel alloc]init];
    if (kScreenWidth == 414) {
        tuPianShuoMingLabel.frame = CGRectMake(20, tuPianImageView.frame.origin.y + tuPianImageView.frame.size.height + space, kScreenWidth - 40, tuPianShuoMingLabelHeight);
        tuPianShuoMingLabel.font = [UIFont systemFontOfSize:20];
    }
    else{
        tuPianShuoMingLabel.frame = CGRectMake(15, tuPianImageView.frame.origin.y + tuPianImageView.frame.size.height + space, kScreenWidth - 30, tuPianShuoMingLabelHeight);
        tuPianShuoMingLabel.font = [UIFont systemFontOfSize:18];
    }
    tuPianShuoMingLabel.textAlignment = NSTextAlignmentCenter;
    tuPianShuoMingLabel.textColor = UIColorFromRGB(0x4fc1e9);
    tuPianShuoMingLabel.text = @"示教及检验伪色盲";
    tuPianShuoMingLabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:tuPianShuoMingLabel];
    
    
    tiShiLabel = [[UILabel alloc]init];
    if (kScreenWidth == 414) {
        tiShiLabel.frame = CGRectMake(20, tuPianShuoMingLabel.frame.origin.y + tuPianShuoMingLabel.frame.size.height + 2*space, kScreenWidth - 40, tiShiLabelHeight);
        tiShiLabel.font = [UIFont systemFontOfSize:15];
    }
    else{
        tiShiLabel.frame = CGRectMake(15, tuPianShuoMingLabel.frame.origin.y + tuPianShuoMingLabel.frame.size.height + 2*space, kScreenWidth - 30, tiShiLabelHeight);
        tiShiLabel.font = [UIFont systemFontOfSize:13];
    }
    tiShiLabel.textAlignment = NSTextAlignmentLeft;
    tiShiLabel.textColor = [UIColor blackColor];
    tiShiLabel.numberOfLines = 2;
    tiShiLabel.lineBreakMode = NSLineBreakByWordWrapping;
    tiShiLabel.text = @"请您在三秒内做出选择，以便达到最好的测试效果，建议您最多不超过10秒钟";
    tiShiLabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:tiShiLabel];
    
    button1 = [[UIButton alloc]init];
    button1.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    button1.layer.borderWidth = 1;
    button1.layer.cornerRadius = 3;
    button1.backgroundColor = [UIColor whiteColor];
    [button1 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
    button1.titleLabel.font = [UIFont systemFontOfSize:20];
    [button1 addTarget:self action:@selector(doButton:) forControlEvents:UIControlEventTouchUpInside];
    button1.hidden = YES;
    [self.view addSubview:button1];
    
    button2 = [[UIButton alloc]init];
    button2.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    button2.layer.borderWidth = 1;
    button2.layer.cornerRadius = 3;
    button2.backgroundColor = [UIColor whiteColor];
    [button2 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
    button2.titleLabel.font = [UIFont systemFontOfSize:20];
    [button2 addTarget:self action:@selector(doButton:) forControlEvents:UIControlEventTouchUpInside];
    button2.hidden = YES;
    [self.view addSubview:button2];
    
    button3 = [[UIButton alloc]init];
    button3.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    button3.layer.borderWidth = 1;
    button3.layer.cornerRadius = 3;
    button3.backgroundColor = [UIColor whiteColor];
    [button3 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
    button3.titleLabel.font = [UIFont systemFontOfSize:20];
    [button3 addTarget:self action:@selector(doButton:) forControlEvents:UIControlEventTouchUpInside];
    button3.hidden = YES;
    [self.view addSubview:button3];
    
    button4 = [[UIButton alloc]init];
    button4.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    button4.layer.borderWidth = 1;
    button4.layer.cornerRadius = 3;
    button4.backgroundColor = [UIColor whiteColor];
    [button4 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
    button4.titleLabel.font = [UIFont systemFontOfSize:20];
    [button4 setTitle:@"不能读" forState:UIControlStateNormal];
    [button4 addTarget:self action:@selector(doButton:) forControlEvents:UIControlEventTouchUpInside];
    button4.hidden = YES;
    [self.view addSubview:button4];
    
    button1.frame = CGRectMake(0, tiShiLabel.frame.origin.y + tiShiLabel.frame.size.height + 2*space, 0, buttonHeight);
    button2.frame = CGRectMake(0, tiShiLabel.frame.origin.y + tiShiLabel.frame.size.height + 2*space, 0, buttonHeight);
    button3.frame = CGRectMake(0, tiShiLabel.frame.origin.y + tiShiLabel.frame.size.height + 2*space, 0, buttonHeight);
    button4.frame = CGRectMake(0, tiShiLabel.frame.origin.y + tiShiLabel.frame.size.height + 2*space, 0, buttonHeight);
    
    currentTestStep = kChangGuiStep;

    tuPianShuoMingLabel.text = @"常规测试";
    [self startTest];
}

- (void)makeNavBar{
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(doBack)];
    [backBtnImg setTintColor:[UIColor whiteColor]];
    self.navigationItem.leftBarButtonItem = backBtnImg;
}

-(void)doBack{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)doButton:(UIButton *)senderButton{
    if ([currentTestStep isEqualToString:kChangGuiStep]) {
//        tuPianShuoMingLabel.text = @"常规测试";
        [self doStep1WithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kXianTian_1234Step]) {
//        tuPianShuoMingLabel.text = @"先天性色觉异常程度测试";
        [self doStep1234WithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kXianTian_123Step]){
//        tuPianShuoMingLabel.text = @"先天性色觉异常程度测试";
        [self doStep123WithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kXianTian_12Step]){
//        tuPianShuoMingLabel.text = @"先天性色觉异常程度测试";
        [self doStep12WithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kRedAndGreenDecideStep]){
//        tuPianShuoMingLabel.text = @"先天性色觉异常程度测试";
        [self doRedAndGreenDecideStepWithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kHouTianHongLvAndPurDecideStep_1]){
//        tuPianShuoMingLabel.text = @"后天性色觉异常测试";
        [self doHongLvAndPurDecideStep1WithTouchedBTN:senderButton];
    }
    else if ([currentTestStep isEqualToString:kHouTianHongLvAndPurDecideStep_2]){
//        tuPianShuoMingLabel.text = @"后天性色觉异常测试";
        [self doHongLvAndPurDecideStep2WithTouchedBTN:senderButton];
    }
}

- (void)startTest{
    if (self.testWay == shuZiTestWay) {
        [changGuiShuZi removeAllObjects];
        changGuiShuZi = [[dataPacketDict valueForKey:kChangGuiShuZi] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForChangGuiShuZiTest];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        [changGuiTuXing removeAllObjects];
        changGuiTuXing = [[dataPacketDict valueForKey:kChangGuiTuXing] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForChangGuiTuXingTest];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        [changGuiHunHe removeAllObjects];
        changGuiHunHe = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kChangGuiShuZi]];
        [changGuiHunHe addObjectsFromArray:[dataPacketDict valueForKey:kChangGuiTuXing]];
        
        NSString *randomSelectedImageName = [self randomSelectImageForChangGuiHunHeTest];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
}

- (void)doStep1WithTouchedBTN:(UIButton *)senderBTN{
    if ((currentTestImageNumber == 1 && [[senderBTN currentTitle] isEqualToString:@"98"]) || (currentTestImageNumber == 14 && [[senderBTN currentTitle] isEqualToString:@"★"]) || (currentTestImageNumber == 15 && [[senderBTN currentTitle] isEqualToString:@"△ O"])) {
        tuPianShuoMingLabel.text = @"常规测试";

        if (self.testWay == shuZiTestWay) {
            [changGuiShuZi removeAllObjects];
            changGuiShuZi = [[dataPacketDict valueForKey:kChangGuiShuZi] mutableCopy];
            
            NSString *randomSelectedImageName = [self randomSelectImageForChangGuiShuZiTest];
            [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
            NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
            NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
            [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
        }
        else if (self.testWay == tuXingTestWay){
            [changGuiTuXing removeAllObjects];
            changGuiTuXing = [[dataPacketDict valueForKey:kChangGuiTuXing] mutableCopy];
            
            NSString *randomSelectedImageName = [self randomSelectImageForChangGuiTuXingTest];
            [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
            NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
            NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
            [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
        }
        else if (self.testWay == hunHeTestWay){
            [changGuiHunHe removeAllObjects];
            changGuiHunHe = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kChangGuiShuZi]];
            [changGuiHunHe addObjectsFromArray:[dataPacketDict valueForKey:kChangGuiTuXing]];
            
            NSString *randomSelectedImageName = [self randomSelectImageForChangGuiHunHeTest];
            [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
            NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
            NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
            [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
        }
    }
    else{
        if (currentTestImageNumber == 2){
            if ([[senderBTN currentTitle] isEqualToString:@"291"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"9"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 4){
            if ([[senderBTN currentTitle] isEqualToString:@"88"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"99"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 10){
            if ([[senderBTN currentTitle] isEqualToString:@"286"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"8"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 41){
            if ([[senderBTN currentTitle] isEqualToString:@"908"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"O"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 44){
            if ([[senderBTN currentTitle] isEqualToString:@"698"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"9"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 48){
            if ([[senderBTN currentTitle] isEqualToString:@"602"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"98"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 16){
            if ([[senderBTN currentTitle] isEqualToString:@"★"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"△"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 20){
            if ([[senderBTN currentTitle] isEqualToString:@"△ O ▽"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"O"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 25){
            if ([[senderBTN currentTitle] isEqualToString:@"O 剪刀"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"O"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 33){
            if ([[senderBTN currentTitle] isEqualToString:@"牛"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"鸡"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        else if (currentTestImageNumber == 35){
            if ([[senderBTN currentTitle] isEqualToString:@"羊"]) {
                seJueZhengChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"鸡"]){
                seJueYiChang += 1;
            }
            else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
                seJueWuFaDuChu += 1;
            }
        }
        
        if (seJueZhengChang > 0 || seJueYiChang > 0 || seJueWuFaDuChu > 0) {
            if (seJueZhengChang == 2) {
                seJueType = 1;
                //出测试报告
                [self giveTheTestReport];
            }
            else if (seJueYiChang == 2){
                seJueType = 2;
                //先天性
                currentTestStep = kXianTian_1234Step;
                tuPianShuoMingLabel.text = @"先天性色觉异常程度测试";
                if (self.testWay == shuZiTestWay) {
                    [xianTianShuZi_1234 removeAllObjects];
                    xianTianShuZi_1234 = [[dataPacketDict valueForKey:kXianTianCeShiShuZi_1234] mutableCopy];
                    
                    NSString *randomSelectedImageName = [self randomSelectImageForXianTianShuZiTest_1234];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == tuXingTestWay){
                    [xianTianTuXing_1234 removeAllObjects];
                    xianTianTuXing_1234 = [[dataPacketDict valueForKey:kXianTianCeShiTuXing_1234] mutableCopy];
                    
                    NSString *randomSelectedImageName = [self randomSelectImageForXianTianTuXingTest_1234];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == hunHeTestWay){
                    [xianTianHunHe_1234 removeAllObjects];
                    xianTianHunHe_1234 = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kXianTianCeShiShuZi_1234]];
                    [xianTianHunHe_1234 addObjectsFromArray:[dataPacketDict valueForKey:kXianTianCeShiTuXing_1234]];
                    
                    NSString *randomSelectedImageName = [self randomSelectImageForXianTianHunHeTest_1234];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
            }
            else if (seJueWuFaDuChu == 2){
                seJueType = 3;
                //后天性
                currentTestStep = kHouTianHongLvAndPurDecideStep_1;
                tuPianShuoMingLabel.text = @"后天性色觉异常测试";
                if (self.testWay == shuZiTestWay) {
                    NSString *randomSelectedImageName = @"seJue_53.png";
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == tuXingTestWay){
                    NSString *randomSelectedImageName = @"seJue_60.png";
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == hunHeTestWay){
                    NSString *randomSelectedImageName;
                    NSInteger j = arc4random() % 2;
                    if (j == 0) {
                        randomSelectedImageName = @"seJue_53.png";
                    }
                    else if (j == 1){
                        randomSelectedImageName = @"seJue_60.png";
                    }
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
            }
            else {
                if (self.testWay == shuZiTestWay) {
                    NSString *randomSelectedImageName = [self randomSelectImageForChangGuiShuZiTest];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == tuXingTestWay){
                    NSString *randomSelectedImageName = [self randomSelectImageForChangGuiTuXingTest];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
                else if (self.testWay == hunHeTestWay){
                    NSString *randomSelectedImageName = [self randomSelectImageForChangGuiHunHeTest];
                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
                }
            }
        }
    }
}

- (void)doStep1234WithTouchedBTN:(UIButton *)senderBTN{
    if (currentTestImageNumber == 3) {
        if ([[senderBTN currentTitle] isEqualToString:@"628"]) {
            seJueLevel = 4;
            //进行红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            [self doTestForDecide123];
        }
    }
    else if (currentTestImageNumber == 5){
        if ([[senderBTN currentTitle] isEqualToString:@"69"]) {
            seJueLevel = 4;
            //进行红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            [self doTestForDecide123];
        }
    }
    else if (currentTestImageNumber == 44){
        if ([[senderBTN currentTitle] isEqualToString:@"698"]) {
            seJueLevel = 4;
            //进行及轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"9"]){
            [self doTestForDecide123];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //再次从3或5中随机选择
            NSString *randomSelectedImageName = [self randomSelectImageForXianTianShuZiTest_1234];
            [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
            NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
            NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
            [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
        }
    }
    else if (currentTestImageNumber == 26) {
        if ([[senderBTN currentTitle] isEqualToString:@"杯"]) {
            seJueLevel = 4;
            //进行及轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            [self doTestForDecide123];
        }
    }
}

- (void)doTestForDecide123{
    //进行123测试
    currentTestStep = kXianTian_123Step;
    if (self.testWay == shuZiTestWay) {
        [xianTianShuZi_123 removeAllObjects];
        xianTianShuZi_123 = [[dataPacketDict valueForKey:kXianTianCeShiShuZi_123] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianShuZiTest_123];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        [xianTianTuXing_123 removeAllObjects];
        xianTianTuXing_123 = [[dataPacketDict valueForKey:kXianTianCeShiTuXing_123] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianTuXingTest_123];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        [xianTianHunHe_123 removeAllObjects];
        xianTianHunHe_123 = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kXianTianCeShiShuZi_123]];
        [xianTianHunHe_123 addObjectsFromArray:[dataPacketDict valueForKey:kXianTianCeShiTuXing_123]];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianHunHeTest_123];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
}

- (void)doStep123WithTouchedBTN:(UIButton *)senderBTN{
    if (currentTestImageNumber == 7) {
        if ([[senderBTN currentTitle] isEqualToString:@"6"]) {
            //进行12测试
            [self doTestForDecide12];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"98"]){
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //从9或者43中随机选中一个再次测试
            NSString *randomSelectedImageName = [self randomSelectImageForXianTianShuZiTest_123];
            [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
            NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
            NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
            [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
        }
    }
    else if (currentTestImageNumber == 9){
        if ([[senderBTN currentTitle] isEqualToString:@"9"]) {
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //进行12测试
            [self doTestForDecide12];
        }
    }
    else if (currentTestImageNumber == 43){
        if ([[senderBTN currentTitle] isEqualToString:@"8609"]) {
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //进行12测试
            [self doTestForDecide12];
        }
    }
    else if (currentTestImageNumber == 18){
        if ([[senderBTN currentTitle] isEqualToString:@"O"]) {
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //进行12测试
            [self doTestForDecide12];
        }
    }
    else if (currentTestImageNumber == 19){
        if ([[senderBTN currentTitle] isEqualToString:@"O ▽"]) {
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //进行12测试
            [self doTestForDecide12];
        }
    }
    else if (currentTestImageNumber == 30){
        if ([[senderBTN currentTitle] isEqualToString:@"蝴蝶"]) {
            seJueLevel = 3;
            //进行轻级红绿色弱判断
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            //进行12测试
            [self doTestForDecide12];
        }
    }
}

- (void)doTestForDecide12{
    if (self.testWay == shuZiTestWay) {
        currentTestStep = kXianTian_12Step;
        [xianTianShuZi_12 removeAllObjects];
        xianTianShuZi_12 = [[dataPacketDict valueForKey:kXianTianCeShiShuZi_12] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianShuZiTest_12];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        currentTestStep = kXianTian_12Step;
        [xianTianTuXing_12 removeAllObjects];
        xianTianTuXing_12 = [[dataPacketDict valueForKey:kXianTianCeShiTuXing_12] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianTuXingTest_12];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        currentTestStep = kXianTian_12Step;
        [xianTianHunHe_12 removeAllObjects];
        xianTianHunHe_12 = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kXianTianCeShiShuZi_12]];
        [xianTianHunHe_12 addObjectsFromArray:[dataPacketDict valueForKey:kXianTianCeShiTuXing_12]];
        
        NSString *randomSelectedImageName = [self randomSelectImageForXianTianHunHeTest_12];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
}

- (void)doStep12WithTouchedBTN:(UIButton *)senderBTN{
    if (currentTestImageNumber == 11) {
        if ([[senderBTN currentTitle] isEqualToString:@"62"]) {
            seJueLevel = 2;
            //次重级，判断次重级红绿色盲
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            seJueLevel = 1;
            //重级,出测试报告
            [self giveTheTestReport];
        }
    }
    else if (currentTestImageNumber == 23){
        if ([[senderBTN currentTitle] isEqualToString:@"壶"]) {
            seJueLevel = 2;
            //次重级，判断次重级红绿色盲
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            seJueLevel = 1;
            //重级,出测试报告
            [self giveTheTestReport];
        }
    }
    else if (currentTestImageNumber == 29){
        if ([[senderBTN currentTitle] isEqualToString:@"燕"]) {
            seJueLevel = 2;
            //次重级，判断次重级红绿色盲
            [self doRedAndGreenDecide];
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            seJueLevel = 1;
            //重级,出测试报告
            [self giveTheTestReport];
        }
    }
}

- (void)doRedAndGreenDecideStepWithTouchedBTN:(UIButton *)senderBTN{
#pragma 次重级、轻级和极轻级需要这个测试
    if ([[senderBTN currentTitle] isEqualToString:@"2"] || [[senderBTN currentTitle] isEqualToString:@"6"] || [[senderBTN currentTitle] isEqualToString:@"▽"] || [[senderBTN currentTitle] isEqualToString:@"O"]) {
        //弹出框提示是否能看清2、9
        if (seJueLevel == 2) {
            seJueRoG = 2;//红色能看见，说明是红色正常或色弱，绿色盲
            //判断是否是红色弱
            [self createSelectRedOrGreenView];
        }
        else if (seJueLevel == 3){
            if (isRedAndGreenDecide == 1) {
                seJueLevel = 2;//判断为次重级
                seJueRoG = 2;//绿色盲
                //判断是否是红色弱
                [self createSelectRedOrGreenView];
            }
            else{
                isRedAndGreenDecide = 1;//标记是重复确认
                [self doRepeatToDecideRedOrGreen];
            }
        }
        else if (seJueLevel == 4){
            if (isRedAndGreenDecide == 1) {
                seJueLevel = 2;//判断为次重级
                seJueRoG = 2;//绿色盲
                //判断是否是红色弱
                [self createSelectRedOrGreenView];
            }
            else{
                isRedAndGreenDecide = 1;//标记是重复确认
                [self doRepeatToDecideRedOrGreen];
            }
        }
    }
    else if ([[senderBTN currentTitle] isEqualToString:@"9"] || [[senderBTN currentTitle] isEqualToString:@"0"] || [[senderBTN currentTitle] isEqualToString:@"□"] || [[senderBTN currentTitle] isEqualToString:@"★"]){
        //弹出框提示是否能看清2、9
        if (seJueLevel == 2) {
            seJueRoG = 1;//绿色能看见，说明是绿色正常或色弱，红色盲
            //判断是否是绿色弱
            [self createSelectRedOrGreenView];
        }
        else if (seJueLevel == 3){
            if (isRedAndGreenDecide == 1) {
                seJueLevel = 2;//判断为次重级
                seJueRoG = 1;//红色盲
                //判断是否是绿色弱
                [self createSelectRedOrGreenView];
            }
            else{
                isRedAndGreenDecide = 1;//标记是重复确认
                [self doRepeatToDecideRedOrGreen];
            }
        }
        else if (seJueLevel == 4){
            if (isRedAndGreenDecide == 1) {
                seJueLevel = 2;//判断为次重级
                seJueRoG = 1;//红色盲
                //判断是否是绿色弱
                [self createSelectRedOrGreenView];
            }
            else{
                isRedAndGreenDecide = 1;//标记是重复确认
                [self doRepeatToDecideRedOrGreen];
            }
        }
    }
    else if ([[senderBTN currentTitle] isEqualToString:@"2和9"] || [[senderBTN currentTitle] isEqualToString:@"6和0"] || [[senderBTN currentTitle] isEqualToString:@"□ ▽"] || [[senderBTN currentTitle] isEqualToString:@"O ★"]){
        if (seJueLevel == 2) {
            if (isRedAndGreenDecide == 1) {
                seJueLevel = 3;
                //轻级红绿色弱判断
                [self createSelectRedOrGreenView];
            }
            else{
                isRedAndGreenDecide = 1;//标记是重复确认
                [self doRepeatToDecideRedOrGreen];
            }
        }
        else if (seJueLevel == 3){
            //轻级红绿色弱
            [self createSelectRedOrGreenView];
        }
        else if (seJueLevel == 4){
            //极轻级红绿色弱
            [self createSelectRedOrGreenView];
        }
    }
    else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
        if (isRedAndGreenDecide == 1) {
            seJueLevel = 1;//判断为重级
            //出测试报告
            [self giveTheTestReport];
        }
        else{
            isRedAndGreenDecide = 1;//标记是重复确认
            [self doRepeatToDecideRedOrGreen];
        }
    }

//    if (currentTestImageNumber == 12 || currentTestImageNumber == 13) {
//        if ([[senderBTN currentTitle] isEqualToString:@"2"] || [[senderBTN currentTitle] isEqualToString:@"6"]) {
//            //弹出框提示是否能看清2、9
//            if (seJueLevel == 2) {
//                seJueRoG = 2;//绿色盲
//                //判断是否是红色弱
//                [self createSelectRedOrGreenView];
//            }
//            else if (seJueLevel == 3){
//                if (isRedAndGreenDecide == 1) {
//                    seJueLevel = 2;//判断为次重级
//                    seJueRoG = 2;//绿色盲
//                    //判断是否是红色弱
//                    [self createSelectRedOrGreenView];
//                }
//                else{
//                    isRedAndGreenDecide = 1;//标记是重复确认
//                    NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//                }
//            }
//            else if (seJueLevel == 4){
//                if (isRedAndGreenDecide == 1) {
//                    seJueLevel = 2;//判断为次重级
//                    seJueRoG = 2;//绿色盲
//                    //判断是否是红色弱
//                    [self createSelectRedOrGreenView];
//                }
//                else{
//                    isRedAndGreenDecide = 1;//标记是重复确认
//                    NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//                }
//            }
//        }
//        else if ([[senderBTN currentTitle] isEqualToString:@"9"] || [[senderBTN currentTitle] isEqualToString:@"0"]){
//            //弹出框提示是否能看清2、9
//            if (seJueLevel == 2) {
//                seJueRoG = 1;//红色盲
//                //判断是否是绿色弱
//                [self createSelectRedOrGreenView];
//            }
//            else if (seJueLevel == 3){
//                if (isRedAndGreenDecide == 1) {
//                    seJueLevel = 2;//判断为次重级
//                    seJueRoG = 1;//红色盲
//                    //判断是否是绿色弱
//                    [self createSelectRedOrGreenView];
//                }
//                else{
//                    isRedAndGreenDecide = 1;//标记是重复确认
//                    NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//                }
//            }
//            else if (seJueLevel == 4){
//                if (isRedAndGreenDecide == 1) {
//                    seJueLevel = 2;//判断为次重级
//                    seJueRoG = 1;//红色盲
//                    //判断是否是绿色弱
//                    [self createSelectRedOrGreenView];
//                }
//                else{
//                    isRedAndGreenDecide = 1;//标记是重复确认
//                    NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//                }
//            }
//        }
//        else if ([[senderBTN currentTitle] isEqualToString:@"2和9"] || [[senderBTN currentTitle] isEqualToString:@"6和0"]){
//            if (seJueLevel == 2) {
//                if (isRedAndGreenDecide == 1) {
//                    seJueLevel = 3;
//                    //轻级红绿色弱判断
//                    [self createSelectRedOrGreenView];
//                }
//                else{
//                    isRedAndGreenDecide = 1;//标记是重复确认
//                    NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                    [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                    NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                    NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                    [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//                }
//            }
//            else if (seJueLevel == 3){
//                //轻级红绿色弱
//                [self createSelectRedOrGreenView];
//            }
//            else if (seJueLevel == 4){
//                //极轻级红绿色弱
//                [self createSelectRedOrGreenView];
//            }
//        }
//        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
//            if (isRedAndGreenDecide == 1) {
//                seJueLevel = 1;//判断为重级
//                //出测试报告
//                [self giveTheTestReport];
//            }
//            else{
//                isRedAndGreenDecide = 1;//标记是重复确认
//                NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
//                [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
//                NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
//                NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
//                [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
//            }
//        }
//    }
}

- (void)doRepeatToDecideRedOrGreen{
    if (self.testWay == shuZiTestWay) {
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenTuXing];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenHunHe];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
}

- (void)doHongLvAndPurDecideStep1WithTouchedBTN:(UIButton *)senderBTN{
    if (currentTestImageNumber == 53) {
        if ([[senderBTN currentTitle] isEqualToString:@"60"]) {
            seJueRG = 0;//红绿色觉正常
        }
        else if ([[senderBTN currentTitle] isEqualToString:@"不能读"]){
            seJueRG = 1;//红绿色觉异常
        }
    }
    currentTestStep = kHouTianHongLvAndPurDecideStep_2;
    if (self.testWay == shuZiTestWay) {
        [houTianCeShiStep2ShuZi removeAllObjects];
        houTianCeShiStep2ShuZi = [[dataPacketDict valueForKey:kHouTianCeShiStep2ShuZi] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForHouTianCeShiStep2ShuZi];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        [houTianCeShiStep2TuXing removeAllObjects];
        houTianCeShiStep2TuXing = [[dataPacketDict valueForKey:kHouTianCeShiStep2TuXing] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForHouTianCeShiStep2TuXing];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        [houTianCeShiStep2HunHe removeAllObjects];
        houTianCeShiStep2HunHe = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kHouTianCeShiStep2ShuZi]];
        [houTianCeShiStep2HunHe addObjectsFromArray:[dataPacketDict valueForKey:kHouTianCeShiStep2TuXing]];
        
        NSString *randomSelectedImageName = [self randomSelectImageForHouTianCeShiStep2HunHe];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }    

}

- (void)doHongLvAndPurDecideStep2WithTouchedBTN:(UIButton *)senderBTN{
    if ([[senderBTN currentTitle] isEqualToString:@"不能读"]) {
        seJueP = 1;//紫色异常
    }
    else{
        seJueP = 0;//紫色正常
    }
    if (seJueP == 1 && seJueRG == 1) {//红绿色和紫色都异常
        seJueType = 4;
    }
    else if (seJueRG == 0 && seJueP == 0){
        seJueType = 3;
    }
    [self giveTheTestReport];
}

- (void)createSelectRedOrGreenView{
    selectRedOrGreenBGView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    selectRedOrGreenBGView.backgroundColor = [UIColor whiteColor];
    selectRedOrGreenBGView.alpha = 0.9;
    [self.view addSubview:selectRedOrGreenBGView];
    
    selectRedOrGreenView = [[UIView alloc]init];
    selectRedOrGreenView.frame = CGRectMake((kScreenWidth - selectRedOrGreenViewWidth)/2, (self.view.frame.size.height - 64 - selectRedOrGreenViewHeight)/2, selectRedOrGreenViewWidth, selectRedOrGreenViewHeight);
    selectRedOrGreenView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:selectRedOrGreenView];
    
    UIImageView *bgImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, selectRedOrGreenViewWidth, selectRedOrGreenViewHeight)];
    bgImageView.image = [UIImage imageNamed:@"test_result_fen_xiang_bg"];
    [selectRedOrGreenView addSubview:bgImageView];
    
    tiShiLabel = [[UILabel alloc]init];
    if (kScreenWidth == 414) {
        tiShiLabel.frame = CGRectMake(0, 37, selectRedOrGreenViewWidth, 24);
    }
    else{
        tiShiLabel.frame = CGRectMake(0, 31, selectRedOrGreenViewWidth, 20);
    }
    tiShiLabel.textAlignment = NSTextAlignmentCenter;
    tiShiLabel.textColor = UIColorFromRGB(0x4fc1e9);
    if (seJueLevel == 2) {
        if (seJueRoG == 1) {
            if (currentTestImageNumber == 12) {
                tiShiLabel.text = @"9是否能看清楚?";
            }
            else if (currentTestImageNumber == 13){
                tiShiLabel.text = @"0是否能看清楚?";
            }
            else if (currentTestImageNumber == 21){
                tiShiLabel.text = @"□是否能看清楚?";
            }
            else if (currentTestImageNumber == 22){
                tiShiLabel.text = @"★是否能看清楚?";
            }
        }
        else if (seJueRoG == 2){
            if (currentTestImageNumber == 12) {
                tiShiLabel.text = @"2是否能看清楚?";
            }
            else if (currentTestImageNumber == 13){
                tiShiLabel.text = @"6是否能看清楚?";
            }
            else if (currentTestImageNumber == 21){
                tiShiLabel.text = @"▽是否能看清楚?";
            }
            else if (currentTestImageNumber == 22){
                tiShiLabel.text = @"O是否能看清楚?";
            }
        }
    }
    else if (seJueLevel == 3 || seJueLevel == 4){//先区分是否红色色弱
        if (currentTestImageNumber == 12) {
            tiShiLabel.text = @"2是否能看清楚?";
        }
        else if (currentTestImageNumber == 13){
            tiShiLabel.text = @"6是否能看清楚?";
        }
        else if (currentTestImageNumber == 21){
            tiShiLabel.text = @"▽是否能看清楚?";
        }
        else if (currentTestImageNumber == 22){
            tiShiLabel.text = @"O是否能看清楚?";
        }
    }
    tiShiLabel.backgroundColor = [UIColor clearColor];
    [selectRedOrGreenView addSubview:tiShiLabel];
    
    UIButton *canSeeBTN = [[UIButton alloc]init];
    if (kScreenWidth == 414) {
        canSeeBTN.frame = CGRectMake(48, 102, 102, 42);
        canSeeBTN.titleLabel.font = [UIFont systemFontOfSize:18];
    }
    else{
        canSeeBTN.frame = CGRectMake(40, 85, 85, 35);
        canSeeBTN.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    canSeeBTN.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    canSeeBTN.layer.borderWidth = 1;
    canSeeBTN.layer.cornerRadius = 3;
    canSeeBTN.backgroundColor = UIColorFromRGB(0x4fc1e9);
    [canSeeBTN setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [canSeeBTN setTitle:@"能看清" forState:UIControlStateNormal];
    [canSeeBTN addTarget:self action:@selector(doCanSee) forControlEvents:UIControlEventTouchUpInside];
    [selectRedOrGreenView addSubview:canSeeBTN];
    
    UIButton *canNotSeeBTN = [[UIButton alloc]initWithFrame:CGRectMake(165, 85, 85, 35)];
    if (kScreenWidth == 414) {
        canNotSeeBTN.frame = CGRectMake(198, 102, 102, 42);
        canNotSeeBTN.titleLabel.font = [UIFont systemFontOfSize:18];
    }
    else{
        canNotSeeBTN.frame = CGRectMake(165, 85, 85, 35);
        canNotSeeBTN.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    canNotSeeBTN.layer.borderColor = UIColorFromRGB(0x4fc1e9).CGColor;
    canNotSeeBTN.layer.borderWidth = 1;
    canNotSeeBTN.layer.cornerRadius = 3;
    canNotSeeBTN.backgroundColor = UIColorFromRGB(0x4fc1e9);
    [canNotSeeBTN setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [canNotSeeBTN setTitle:@"看不清" forState:UIControlStateNormal];
    [canNotSeeBTN addTarget:self action:@selector(doCanNotSee) forControlEvents:UIControlEventTouchUpInside];
    [selectRedOrGreenView addSubview:canNotSeeBTN];
    
    
}

- (void)doCanSee{
    if (seJueLevel == 2) {
        if (seJueRoG == 1) {
            seJueG = 0;
            [self giveTheTestReport];
        }
        else if (seJueRoG == 2){
            seJueR = 0;
            [self giveTheTestReport];
        }
    }
    else if (seJueLevel == 3 || seJueLevel == 4){
        if (isSecondDecideRedAndGreen == 1) {
            seJueG = 0;
            [self giveTheTestReport];
        }
        else{
            seJueR = 0;
            isSecondDecideRedAndGreen = 1;
            
            if (currentTestImageNumber == 12) {//用于区分绿色是否色弱
                tiShiLabel.text = @"9是否能看清楚?";
            }
            else if (currentTestImageNumber == 13){
                tiShiLabel.text = @"0是否能看清楚?";
            }
            else if (currentTestImageNumber == 21){
                tiShiLabel.text = @"□是否能看清楚?";
            }
            else if (currentTestImageNumber == 22){
                tiShiLabel.text = @"★是否能看清楚?";
            }
        }
    }
}

- (void)doCanNotSee{
    if (seJueLevel == 2) {
        if (seJueRoG == 1) {
            seJueG = 1;
            [self giveTheTestReport];
//            [self createSelectRedOrGreenView];
        }
        else if (seJueRoG == 2){
            seJueR = 1;
            [self giveTheTestReport];
//            [self createSelectRedOrGreenView];
        }
        
    }
    else if (seJueLevel == 3 || seJueLevel == 4){
        if (isSecondDecideRedAndGreen == 1) {
            seJueG = 1;
            [self giveTheTestReport];
//            [self createSelectRedOrGreenView];
        }
        else{
            seJueR = 1;
            isSecondDecideRedAndGreen = 1;
            
            if (currentTestImageNumber == 12) {//用于区分绿色是否色弱
                tiShiLabel.text = @"9是否能看清楚?";
            }
            else if (currentTestImageNumber == 13){
                tiShiLabel.text = @"0是否能看清楚?";
            }
            else if (currentTestImageNumber == 21){
                tiShiLabel.text = @"□是否能看清楚?";
            }
            else if (currentTestImageNumber == 22){
                tiShiLabel.text = @"★是否能看清楚?";
            }
        }
    }
}

- (void)giveTheTestReport{//给出测试报告
    if (seJueType == 1) {//正常
        MyNSLog("正常");
        [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",zhengChang],kSeJueTestResult, nil]];
    }
    else if (seJueType == 2){
        if (seJueLevel == 1) {//重级
            MyNSLog("红绿色盲");
            [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongLvSeMang],kSeJueTestResult, nil]];
        }
        else if (seJueLevel == 2){//次重级
            if (seJueRoG == 1) {
                if (seJueG == 0) {//红色盲，绿色正常
                    MyNSLog("红色盲，绿色正常");
                    [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeMangAndLvSeZhengChang],kSeJueTestResult, nil]];
                }
                else if (seJueG == 1){//红色盲，绿色色弱
                    MyNSLog("红色盲，绿色色弱");
                    [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeMangAndLvSeRuo],kSeJueTestResult, nil]];
                }
            }
            else if (seJueRoG == 2){
                if (seJueR == 0) {//绿色盲，红色正常
                    MyNSLog("绿色盲，红色正常");
                    [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",lvSeMangAndHongSeZhengChang],kSeJueTestResult, nil]];
                }
                else if (seJueR == 1){//绿色盲，红色色弱
                    MyNSLog("绿色盲，红色色弱");
                    [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",lvSeMangAndHongSeRuo],kSeJueTestResult, nil]];
                }
            }
        }
        else if (seJueLevel == 3){
            if (seJueR == 1 && seJueG == 1) {//红色弱，绿色弱
                MyNSLog("红色弱，绿色弱");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeRuoAndLvSeRuo],kSeJueTestResult, nil]];
            }
            else if (seJueR == 1 && seJueG == 0){//红色弱，绿色正常
                MyNSLog("红色弱，绿色正常");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeRuoAndLvSeZhengChang],kSeJueTestResult, nil]];
            }
            else if (seJueR == 0 && seJueG == 1){//红色正常，绿色色弱
                MyNSLog("红色正常，绿色色弱");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeZhengChangAndLvSeRuo],kSeJueTestResult, nil]];
            }
            else if (seJueR == 0 && seJueG == 0){//红色正常，绿色正常
                MyNSLog("红色正常，绿色正常");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeZhengChangAndLvSeZhengChang_level3],kSeJueTestResult, nil]];
            }
        }
        else if (seJueLevel == 4){
            if (seJueR == 1 && seJueG == 1) {//红色极弱，绿色极弱
                MyNSLog("红色极弱，绿色极弱");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeJiRuoAndLvSeJiRuo],kSeJueTestResult, nil]];
            }
            else if (seJueR == 1 && seJueG == 0){//红色极弱，绿色正常
                MyNSLog("红色极弱，绿色正常");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeJiRuoAndLvSeZhengChang],kSeJueTestResult, nil]];
            }
            else if (seJueR == 0 && seJueG == 1){//红色正常，绿色极弱
                MyNSLog("红色正常，绿色极弱");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeZhengChangAndLvSeJiRuo],kSeJueTestResult, nil]];
            }
            else if (seJueR == 0 && seJueG == 0){//红色正常，绿色正常
                MyNSLog("红色正常，绿色正常");
                [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",hongSeZhengChangAndLvSeZhengChang_level4],kSeJueTestResult, nil]];
            }
        }
    }
    else if (seJueType == 3){//后天性
        if (seJueRG == 1 && seJueP == 0) {//后天性红绿色异常，紫色正常
            MyNSLog("后天性红绿色异常，紫色正常");
            [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",houTianHongLvYiChangAndZiSeZhengChang],kSeJueTestResult, nil]];
        }
        else if (seJueRG == 0 && seJueP == 1){//后天性红绿色正常，紫色异常
            MyNSLog("后天性红绿色正常，紫色异常");
            [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",houTianHongLvZhengChangAndZiSeYiChang],kSeJueTestResult, nil]];
        }
        else if (seJueRG == 0 && seJueP == 0){//后天性红绿色或紫色可能异常
            MyNSLog("后天性红绿色或紫色可能异常");
            [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",houTianHongLvAndZiSeKeNengYiChang],kSeJueTestResult, nil]];
        }
    }
    else if (seJueType == 4){//全色盲
        MyNSLog("全色盲");
        [self.seJueTestViewController seJueTestFinishedWithUserResult:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",seJueType],kSeJueTestType,[NSString stringWithFormat:@"%d",quanSeMang],kSeJueTestResult, nil]];
    }
}

- (void)doRedAndGreenDecide{
    currentTestStep = kRedAndGreenDecideStep;
    if (self.testWay == shuZiTestWay) {
        [redAndGreenDecideShuZi removeAllObjects];
        redAndGreenDecideShuZi = [[dataPacketDict valueForKey:kRedAndGreenDecideShuZi] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenShuZi];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == tuXingTestWay){
        [redAndGreenDecideTuXing removeAllObjects];
        redAndGreenDecideTuXing = [[dataPacketDict valueForKey:kRedAndGreenDecideTuXing] mutableCopy];
        
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenTuXing];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
    else if (self.testWay == hunHeTestWay){
        [redAndGreenDecideHunHe removeAllObjects];
        redAndGreenDecideHunHe = [NSMutableArray arrayWithArray:[dataPacketDict valueForKey:kRedAndGreenDecideShuZi]];
        [redAndGreenDecideHunHe addObjectsFromArray:[dataPacketDict valueForKey:kRedAndGreenDecideTuXing]];
        
        NSString *randomSelectedImageName = [self randomSelectImageForRedAndGreenHunHe];
        [tuPianImageView setImage:[UIImage imageNamed:randomSelectedImageName]];
        NSString *randomSelectedImageNumber = [self getImageNumberWithCurrentShowImageName:randomSelectedImageName];
        NSArray *allButtonForThisSelectedImage = [[allDataDict valueForKey:randomSelectedImageNumber] allKeys];
        [self setAdjustsFrameAndTitleForButton:allButtonForThisSelectedImage andIsShiJiao:NO];
    }
}

- (void)initAllData{
    NSMutableDictionary *dataDict = [[NSMutableDictionary alloc]init];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"291"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"9"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"2"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"628"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"3"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang, nil] forKey:@"88"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"99"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"4"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"69"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"5"];
    
//    [dataDict removeAllObjects];
//    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"60"];
//    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"不能读"];
//    [allDataDict setObject:[dataDict copy] forKey:@"6"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"98"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"6"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"7"];
    
//    [dataDict removeAllObjects];
//    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"816"];
//    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
//    [allDataDict setObject:[dataDict copy] forKey:@"8"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"9"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"9"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang, nil] forKey:@"286"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"8"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"10"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"62"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"11"];
    
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"2"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"9"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"2和9"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"12"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"6"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"0"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"6和0"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"13"];
    
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang, nil] forKey:@"★"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"△"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"16"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"O"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"18"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"O ▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"19"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang, nil] forKey:@"△ O ▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"20"];
    
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"□"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"□ ▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"21"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"□"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianCiZhongJi, nil] forKey:@"▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"□ ▽"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"22"];

    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"壶"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"23"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"O 剪刀"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"25"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"杯"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"26"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"燕"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"29"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"蝴蝶"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"30"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"牛"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"鸡"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"33"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"羊"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"鸡"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"35"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang, nil] forKey:@"908"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"41"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianQingJi,kXianTianJiQingJi, nil] forKey:@"8609"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"43"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"698"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"9"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"44"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kZhengChang,kXianTianJiQingJi, nil] forKey:@"602"];
    [dataDict setObject:[NSArray arrayWithObjects:kXianTianZhongJi,kXianTianCiZhongJi,kXianTianQingJi, nil] forKey:@"98"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianSeJueZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"48"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianHongLvZhengChang_ZiSeKeNengZhangAi, nil] forKey:@"60"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianHongLvYiChang_ZiSeKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"53"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"266"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"54"];

    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"928"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"55"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"68"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"56"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"26"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"57"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"16"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"58"];
 
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianHongLvZhengChang_ZiSeKeNengZhangAi, nil] forKey:@"O □"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianHongLvYiChang_ZiSeKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"60"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"O △"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"61"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"□ O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"62"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"△ O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"63"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"△ □"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"64"];
    
    [dataDict removeAllObjects];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeZhengChang_HongLvKeNengZhangAi, nil] forKey:@"O O"];
    [dataDict setObject:[NSArray arrayWithObjects:kHouTianZiSeYiChang_HongLvKeNengZhangAi, nil] forKey:@"不能读"];
    [allDataDict setObject:[dataDict copy] forKey:@"65"];

}

- (void)doDataPacket{
    NSArray *changGuiCeShi_ShuZi = [NSArray arrayWithObjects:@"seJue_2.png",@"seJue_4.png",@"seJue_10.png",@"seJue_41.png",@"seJue_44.png",@"seJue_48.png", nil];
    NSArray *changGuiCeShi_TuXing = [NSArray arrayWithObjects:@"seJue_16.png",@"seJue_20.png",@"seJue_25.png",@"seJue_33.png",@"seJue_35.png", nil];
    [dataPacketDict setObject:changGuiCeShi_ShuZi forKey:kChangGuiShuZi];
    [dataPacketDict setObject:changGuiCeShi_TuXing forKey:kChangGuiTuXing];

    NSArray *xianTianCeShi_ShuZi_1234 = [NSArray arrayWithObjects:@"seJue_3.png",@"seJue_5.png",@"seJue_44.png", nil];
    NSArray *xianTianCeShi_TuPian_1234 = [NSArray arrayWithObjects:@"seJue_26.png", nil];
    [dataPacketDict setObject:xianTianCeShi_ShuZi_1234 forKey:kXianTianCeShiShuZi_1234];
    [dataPacketDict setObject:xianTianCeShi_TuPian_1234 forKey:kXianTianCeShiTuXing_1234];
    
    NSArray *xianTianCeShi_ShuZi_123 = [NSArray arrayWithObjects:@"seJue_7.png",@"seJue_9.png",@"seJue_43.png", nil];
    NSArray *xianTianCeShi_TuPian_123 = [NSArray arrayWithObjects:@"seJue_18.png",@"seJue_19.png",@"seJue_30.png", nil];
    [dataPacketDict setObject:xianTianCeShi_ShuZi_123 forKey:kXianTianCeShiShuZi_123];
    [dataPacketDict setObject:xianTianCeShi_TuPian_123 forKey:kXianTianCeShiTuXing_123];

    NSArray *xianTianCeShi_ShuZi_12 = [NSArray arrayWithObjects:@"seJue_11.png", nil];
    NSArray *xianTianCeShi_TuPian_12 = [NSArray arrayWithObjects:@"seJue_23.png",@"seJue_29.png", nil];
    [dataPacketDict setObject:xianTianCeShi_ShuZi_12 forKey:kXianTianCeShiShuZi_12];
    [dataPacketDict setObject:xianTianCeShi_TuPian_12 forKey:kXianTianCeShiTuXing_12];

    NSArray *redAndGreenDecideTestShuZi = [NSArray arrayWithObjects:@"seJue_12.png",@"seJue_13.png", nil];
    NSArray *redAndGreenDecideTestTuXing = [NSArray arrayWithObjects:@"seJue_21.png",@"seJue_22.png", nil];
    [dataPacketDict setObject:redAndGreenDecideTestShuZi forKey:kRedAndGreenDecideShuZi];
    [dataPacketDict setObject:redAndGreenDecideTestTuXing forKey:kRedAndGreenDecideTuXing];
    
    NSArray *houTianCeShi_ShuZi = [NSArray arrayWithObjects:@"seJue_54.png",@"seJue_55.png",@"seJue_56.png",@"seJue_57.png",@"seJue_58.png", nil];
    NSArray *houTianCeShi_TuXing = [NSArray arrayWithObjects:@"seJue_61.png",@"seJue_62.png",@"seJue_63.png",@"seJue_64.png",@"seJue_65.png", nil];
    [dataPacketDict setObject:houTianCeShi_ShuZi forKey:kHouTianCeShiStep2ShuZi];
    [dataPacketDict setObject:houTianCeShi_TuXing forKey:kHouTianCeShiStep2TuXing];
}

/**
 *  @param titlesArray 数组里元素不包括“不能读”按钮，所以总的按钮个数 = 数组中元素个数 + 1，数组里每个元素都是NSString类型
 */
- (void)setAdjustsFrameAndTitleForButton:(NSArray *)titlesArray andIsShiJiao:(BOOL)isShiJiao{
    button1.hidden = YES;
    button1.userInteractionEnabled = NO;
    button2.hidden = YES;
    button2.userInteractionEnabled = NO;
    button3.hidden = YES;
    button3.userInteractionEnabled = NO;
    button4.hidden = YES;
    button4.userInteractionEnabled = NO;
    
    NSMutableArray *currentTitlesArray = [titlesArray mutableCopy];
    if ([currentTitlesArray containsObject:@"不能读"]) {
        NSInteger index = [currentTitlesArray indexOfObject:@"不能读"];
        [currentTitlesArray exchangeObjectAtIndex:index withObjectAtIndex:(currentTitlesArray.count - 1)];
        
        if (currentTitlesArray.count >= 2) {
            [button1 setTitle:[currentTitlesArray objectAtIndex:0] forState:UIControlStateNormal];
            button1.hidden = NO;
            button1.userInteractionEnabled = YES;
            button1.backgroundColor = [UIColor whiteColor];
            [button1 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        if (currentTitlesArray.count >= 3) {
            [button2 setTitle:[currentTitlesArray objectAtIndex:1] forState:UIControlStateNormal];
            button2.hidden = NO;
            button2.userInteractionEnabled = YES;
            button2.backgroundColor = [UIColor whiteColor];
            [button2 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        if (currentTitlesArray.count >= 4) {
            [button3 setTitle:[currentTitlesArray objectAtIndex:2] forState:UIControlStateNormal];
            button3.hidden = NO;
            button3.userInteractionEnabled = YES;
            button3.backgroundColor = [UIColor whiteColor];
            [button3 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        button4.hidden = NO;
        button4.userInteractionEnabled = YES;
        button4.backgroundColor = [UIColor whiteColor];
        [button4 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        
        if (isShiJiao) {
            button2.backgroundColor = [UIColor grayColor];
            button2.userInteractionEnabled = NO;
            [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            button4.backgroundColor = [UIColor grayColor];
            button4.userInteractionEnabled = NO;
            [button4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        }
        
        if (currentTitlesArray.count == 4) {
            CGFloat space;
            CGFloat buttonWidth;
            if (kScreenWidth == 414) {
                space = (kScreenWidth - 78*4)/6;
                buttonWidth = 78;
            }
            else{
                space = (kScreenWidth - 65*4)/6;
                buttonWidth = 65;
            }
            button1.frame = CGRectMake(space*1.5, button1.frame.origin.y, buttonWidth, button1.frame.size.height);
            
            button2.frame = CGRectMake(button1.frame.origin.x + button1.frame.size.width + space, button2.frame.origin.y, buttonWidth, button2.frame.size.height);
            
            button3.frame = CGRectMake(button2.frame.origin.x + button2.frame.size.width + space, button3.frame.origin.y, buttonWidth, button3.frame.size.height);
            
            button4.frame = CGRectMake(button3.frame.origin.x + button3.frame.size.width + space, button4.frame.origin.y, buttonWidth, button4.frame.size.height);
        }
        else if (currentTitlesArray.count == 3){
            CGFloat space;
            CGFloat buttonWidth;
            if (kScreenWidth == 414) {
                space = (kScreenWidth - 102*3)/5;
                buttonWidth = 102;
            }
            else{
                space = (kScreenWidth - 85*3)/5;
                buttonWidth = 85;
            }
            button1.frame = CGRectMake(space*1.5, button1.frame.origin.y, buttonWidth, button1.frame.size.height);
            button2.frame = CGRectMake(button1.frame.origin.x + button1.frame.size.width + space, button2.frame.origin.y, buttonWidth, button2.frame.size.height);
            button4.frame = CGRectMake(button2.frame.origin.x + button2.frame.size.width + space, button4.frame.origin.y, buttonWidth, button4.frame.size.height);
        }
        else if (currentTitlesArray.count == 2){
            CGFloat space;
            CGFloat buttonWidth;
            if (kScreenWidth == 414) {
                space = (kScreenWidth - 159*2)/4;
                buttonWidth = 159;
            }
            else{
                space = (kScreenWidth - 133*2)/4;
                buttonWidth = 133;
            }
            button1.frame = CGRectMake(space*1.5, button1.frame.origin.y, buttonWidth, button1.frame.size.height);
            button4.frame = CGRectMake(button1.frame.origin.x + button1.frame.size.width + space, button4.frame.origin.y, buttonWidth, button4.frame.size.height);
        }
        else if (currentTitlesArray.count == 1){
            button4.frame = CGRectMake((kScreenWidth - 290)/2, button4.frame.origin.y, 290, button4.frame.size.height);
        }
    }
    else{
        if (currentTitlesArray.count >= 1) {
            [button1 setTitle:[currentTitlesArray objectAtIndex:0] forState:UIControlStateNormal];
            button1.hidden = NO;
            button1.userInteractionEnabled = YES;
            button1.backgroundColor = [UIColor whiteColor];
            [button1 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        if (currentTitlesArray.count >= 2) {
            [button2 setTitle:[currentTitlesArray objectAtIndex:1] forState:UIControlStateNormal];
            button2.hidden = NO;
            button2.userInteractionEnabled = YES;
            button2.backgroundColor = [UIColor whiteColor];
            [button2 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        if (currentTitlesArray.count >= 3) {
            [button3 setTitle:[currentTitlesArray objectAtIndex:2] forState:UIControlStateNormal];
            button3.hidden = NO;
            button3.userInteractionEnabled = YES;
            button3.backgroundColor = [UIColor whiteColor];
            [button3 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];
        }
        button4.hidden = YES;
        button4.userInteractionEnabled = NO;
        button4.backgroundColor = [UIColor whiteColor];
        [button4 setTitleColor:UIColorFromRGB(0x4fc1e9) forState:UIControlStateNormal];

        if (currentTitlesArray.count == 3){
            CGFloat space;
            CGFloat buttonWidth;
            if (kScreenWidth == 414) {
                space = (kScreenWidth - 85*3)/5;
                buttonWidth = 102;
            }
            else{
                space = (kScreenWidth - 85*3)/5;
                buttonWidth = 85;
            }
            button1.frame = CGRectMake(space*1.5, button1.frame.origin.y, buttonWidth, button1.frame.size.height);
            button2.frame = CGRectMake(button1.frame.origin.x + button1.frame.size.width + space, button2.frame.origin.y, buttonWidth, button2.frame.size.height);
            button3.frame = CGRectMake(button2.frame.origin.x + button2.frame.size.width + space, button3.frame.origin.y, buttonWidth, button3.frame.size.height);
        }
        else if (currentTitlesArray.count == 2){
            CGFloat space;
            CGFloat buttonWidth;
            if (kScreenWidth == 414) {
                space = (kScreenWidth - 159*2)/4;
                buttonWidth = 159;
            }
            else{
                space = (kScreenWidth - 133*2)/4;
                buttonWidth = 133;
            }
            button1.frame = CGRectMake(space*1.5, button1.frame.origin.y, buttonWidth, button1.frame.size.height);
            button2.frame = CGRectMake(button1.frame.origin.x + button1.frame.size.width + space, button2.frame.origin.y, buttonWidth, button2.frame.size.height);
        }
        else if (currentTitlesArray.count == 1){
            button1.frame = CGRectMake((kScreenWidth - 290)/2, button1.frame.origin.y, 290, button1.frame.size.height);
        }
    }
}

- (NSString *)randomSelectImageForChangGuiShuZiTest{
    NSInteger j = arc4random() % (changGuiShuZi.count);
    NSString *selectedImageName = [changGuiShuZi objectAtIndex:j];
    [changGuiShuZi removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForChangGuiTuXingTest{
    NSInteger j = arc4random() % (changGuiTuXing.count);
    NSString *selectedImageName = [changGuiTuXing objectAtIndex:j];
    [changGuiTuXing removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForChangGuiHunHeTest{
    NSInteger j = arc4random() % (changGuiHunHe.count);
    NSString *selectedImageName = [changGuiHunHe objectAtIndex:j];
    [changGuiHunHe removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)randomSelectImageForXianTianShuZiTest_1234{
    NSInteger j = arc4random() % (xianTianShuZi_1234.count);
    NSString *selectedImageName = [xianTianShuZi_1234 objectAtIndex:j];
    [xianTianShuZi_1234 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianTuXingTest_1234{
    NSInteger j = arc4random() % (xianTianTuXing_1234.count);
    NSString *selectedImageName = [xianTianTuXing_1234 objectAtIndex:j];
    [xianTianTuXing_1234 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianHunHeTest_1234{
    NSInteger j = arc4random() % (xianTianHunHe_1234.count);
    NSString *selectedImageName = [xianTianHunHe_1234 objectAtIndex:j];
    [xianTianHunHe_1234 removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)randomSelectImageForXianTianShuZiTest_123{
    NSInteger j = arc4random() % (xianTianShuZi_123.count);
    NSString *selectedImageName = [xianTianShuZi_123 objectAtIndex:j];
    [xianTianShuZi_123 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianTuXingTest_123{
    NSInteger j = arc4random() % (xianTianTuXing_123.count);
    NSString *selectedImageName = [xianTianTuXing_123 objectAtIndex:j];
    [xianTianTuXing_123 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianHunHeTest_123{
    NSInteger j = arc4random() % (xianTianHunHe_123.count);
    NSString *selectedImageName = [xianTianHunHe_123 objectAtIndex:j];
    [xianTianHunHe_123 removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)randomSelectImageForXianTianShuZiTest_12{
    NSInteger j = arc4random() % (xianTianShuZi_12.count);
    NSString *selectedImageName = [xianTianShuZi_12 objectAtIndex:j];
    [xianTianShuZi_12 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianTuXingTest_12{
    NSInteger j = arc4random() % (xianTianTuXing_12.count);
    NSString *selectedImageName = [xianTianTuXing_12 objectAtIndex:j];
    [xianTianTuXing_12 removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForXianTianHunHeTest_12{
    NSInteger j = arc4random() % (xianTianHunHe_12.count);
    NSString *selectedImageName = [xianTianHunHe_12 objectAtIndex:j];
    [xianTianHunHe_12 removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)randomSelectImageForRedAndGreenShuZi{
    NSInteger j = arc4random() % (redAndGreenDecideShuZi.count);
    NSString *selectedImageName = [redAndGreenDecideShuZi objectAtIndex:j];
    [redAndGreenDecideShuZi removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForRedAndGreenTuXing{
    NSInteger j = arc4random() % (redAndGreenDecideTuXing.count);
    NSString *selectedImageName = [redAndGreenDecideTuXing objectAtIndex:j];
    [redAndGreenDecideTuXing removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForRedAndGreenHunHe{
    NSInteger j = arc4random() % (redAndGreenDecideHunHe.count);
    NSString *selectedImageName = [redAndGreenDecideHunHe objectAtIndex:j];
    [redAndGreenDecideHunHe removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)randomSelectImageForHouTianCeShiStep2ShuZi{
    NSInteger j = arc4random() % (houTianCeShiStep2ShuZi.count);
    NSString *selectedImageName = [houTianCeShiStep2ShuZi objectAtIndex:j];
    [houTianCeShiStep2ShuZi removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForHouTianCeShiStep2TuXing{
    NSInteger j = arc4random() % (houTianCeShiStep2TuXing.count);
    NSString *selectedImageName = [houTianCeShiStep2TuXing objectAtIndex:j];
    [houTianCeShiStep2TuXing removeObjectAtIndex:j];
    return selectedImageName;
}

- (NSString *)randomSelectImageForHouTianCeShiStep2HunHe{
    NSInteger j = arc4random() % (houTianCeShiStep2HunHe.count);
    NSString *selectedImageName = [houTianCeShiStep2HunHe objectAtIndex:j];
    [houTianCeShiStep2HunHe removeObjectAtIndex:j];
    return selectedImageName;
}


- (NSString *)getImageNumberWithCurrentShowImageName:(NSString *)imageName{
    NSRange rangeLeft = [imageName rangeOfString:@"seJue_"];
    NSRange rangeRight = [imageName rangeOfString:@".png"];
    NSString *number = [imageName substringWithRange:NSMakeRange(rangeLeft.location + rangeLeft.length, rangeRight.location - (rangeLeft.location + rangeLeft.length))];
    currentTestImageNumber = [number integerValue];
    return number;
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
